﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/BaseMaster/DetailPages.Master" AutoEventWireup="true" CodeBehind="MenuDetail.aspx.cs" Inherits="Liu_Project.Web.Admin.Pages.Personal.EntMenu.MenuDetail" %>

<asp:Content ID="Content1" ContentPlaceHolderID="DetailTitle" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="DetailHead" runat="server">
    <style>
        .layui-form-pane .layui-form-label {
            width: 120px !important;
        }

        .layui-form-pane .layui-input-block {
            margin-left: 120px !important;
        }
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="DetailContent" runat="server">
    <div class="layui-card">
        <form class="layui-form layui-form-pane" lay-filter="menuForm" style="padding: 20px;">
            <div class="layui-form-item">
                <label class="layui-form-label">上级菜单名称</label>
                <div class="layui-input-block">
                    <input type="text" name="ParentMenuName" lay-vertype="tips" autocomplete="off" class="layui-input" disabled maxlength="10">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">菜单名称</label>
                <div class="layui-input-block">
                    <input type="text" name="MenuName" placeholder="请输入菜单名称" lay-verify="required|menuname" lay-vertype="tips" autocomplete="off" class="layui-input" maxlength="8">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">图标</label>
                <div class="layui-input-block">
                    <input type="text" name="MenuIcon" id="iconFonts" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" pane="">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="IsVisiable" lay-skin="switch" lay-text="正常|禁用" checked>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="*">保存</button>
                    <button type="button" id="cancel" class="layui-btn layui-btn-primary">取消</button>
                </div>
            </div>
        </form>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="DetailScript" runat="server">
    <script>
        var CurrData = {};

        function setData(data) {
            CurrData = objDeepCopy(data);
            CurrData._state = "Edit";
            layui.form.val("menuForm", CurrData);

            layui.iconHhysFa.render({
                // 选择器，推荐使用input
                elem: '#iconFonts',
                // 数据类型：fontClass/awesome，推荐使用fontClass
                type: 'fontClass',
                // 是否开启搜索：true/false，默认true
                search: true,
                // 是否开启分页：true/false，默认true
                page: true,
                // 每页显示数量，默认12
                limit: 12,
                url: '',
                // 点击回调
                click: function (data) {
                    console.log(data);
                },
                // 渲染成功后的回调
                success: function (d) {
                    layui.iconHhysFa.checkIcon("iconFonts", CurrData.MenuIcon);
                }
            });

        }

        layui.form.verify({
            menuname: function (value, item) {//value：表单的值、item：表单的DOM对象
                if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
                    return '不能有特殊字符';
                }
                if (/(^\_)|(\__)|(\_+$)/.test(value)) {
                    return '首尾不能出现下划线\'_\'';
                }
                if (/^\d+\d+\d$/.test(value)) {
                    return '不能全为数字';
                }
            }
        });

        layui.form.on('submit(*)', function (data) {
            if (data.field.IsVisiable == "on")
                data.field.IsVisiable = 1;
            else
                data.field.IsVisiable = 0;
            UpdateJson(CurrData, data.field);

            top.layer.load(1);
            GetObjectInfoFunction_Async("Admin/Handler/BaseHand/MenuHand.ashx", {
                "act": "UpdateMenu", "Data": JSON.stringify(CurrData)
            }, function (result) {
                if (result.IsSuccess) {
                    if (result.data.length == 0)
                        return;
                    top.layer.msg('保存成功');
                    parent.layui.table.reload("tableGrid");
                    close();
                }
            });

            return false;
        });

        $("#cancel").click(function () {
            close();
        });

        function close() {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        }

    </script>
</asp:Content>
